package com.design.movieticket.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.design.movieticket.dto.CouponDto;
import com.design.movieticket.entity.Coupon;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

public interface CouponMapper extends BaseMapper<Coupon> {
    @Select("SELECT a.id,b.coupon_name,b.coupon_type,b.details,b.start_pay,b.coupon_discount,b.coupon_start_time,coupon_end_time FROM user_coupon a\n" +
            "LEFT JOIN coupon b\n" +
            "on a.coupon_id = b.id\n" +
            "where a.user_id = #{userId} and a.del_flag = 0")
    List<CouponDto> wxGetMyCouponList(Long userId);

    @Select("SELECT * from coupon where #{nowTime} between coupon_start_time and coupon_end_time and del_flag = 0 order by coupon_type,coupon_name")
    List<Coupon> wxGetCouponList(String nowTime);
}
